package com.qf.user.controller;

import com.qf.core.dto.PageDto;
import com.qf.core.vo.PageResult;
import com.qf.core.vo.R;
import com.qf.user.entity.Role;
import com.qf.user.entity.User;
import com.qf.user.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 角色管理 前端控制器
 * </p>
 *
 * @author yxh
 * @since 2023-10-29
 */
@RestController
@CrossOrigin
@RequestMapping("/role")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @PostMapping("page")
    public PageResult page(@RequestBody PageDto<Role> pageDto){
        return roleService.findPage(pageDto);
    }

    @PostMapping("add")
    public R add(@RequestBody Role role){
        return roleService.add(role);
    }

    @PostMapping("update")
    public R update(@RequestBody Role role){
        return roleService.update(role);
    }

    @PostMapping("/delete/{id}")
    public R delete(@PathVariable("id") String id){
        roleService.removeById(id);
        return R.ok("删除成功");
    }






}
